package com.shujia.sql

import org.apache.spark.sql.{DataFrame, SparkSession}

object Demo10OnHIve {
  def main(args: Array[String]): Unit = {


    val spark: SparkSession = SparkSession.builder()
      .appName("hive")
      .config("spark.sql.shuffle.partitions", "2")
      //使用hive的元数据
      .enableHiveSupport()
      .getOrCreate()

    //戒指结果hive中的表
    val df: DataFrame = spark.table("student")

    df.show()


    spark.sql(
      """
        |
        |select gender ,count(*) from student group by gender
        |
      """.stripMargin)
      .show()

    /**
      *
      * spark-submit --class com.shujia.sql.Demo10OnHIve --master yarn-client spark-1.0.jar
      *
      */
  }
}
